-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for dockerfiles #81
Add support for dockerfiles #81
Conversation
Signed-off-by: lachmanfrantisek <[email protected]>
Signed-off-by: lachmanfrantisek <[email protected]>
Signed-off-by: lachmanfrantisek <[email protected]>
Signed-off-by: lachmanfrantisek <[email protected]>
Signed-off-by: lachmanfrantisek <[email protected]>
Signed-off-by: lachmanfrantisek <[email protected]>
Signed-off-by: lachmanfrantisek <[email protected]>
colin/checks/abstract/dockerfile.py
Outdated
for inst in dfp.structure: | ||
if inst["instruction"] == instruction: | ||
result.append(inst) | ||
return result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you know list comprehensions, I'm just wondering why you don't use it here:
return [inst for inst in dfp.structure if inst["instruction"] == instruction]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neither am I...;-) Thanks!
Signed-off-by: lachmanfrantisek <[email protected]>
Signed-off-by: lachmanfrantisek <[email protected]>
Signed-off-by: lachmanfrantisek <[email protected]>
It needs some polishing but I'm prepared for some review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too long for me doing a code review.
Tested locally on a bunch of Dockerfiles and worked like a charm, very nice work!
colin/checks/dockerfile/from_tag.py
Outdated
message="", | ||
description="", | ||
reference_url="https://docs.docker.com/engine/reference/builder/#from", | ||
tags=["from", "dockerfile", "latest"], | ||
instruction="FROM", | ||
regex=".*/latest$", | ||
value_regex=".*/latest$", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FROM fedora
is also bad, we should catch that one as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there is a TODO for this on the next line:
TODO: Does not check if there is no tag => use ImageName parsing.
It will not be hard to do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Signed-off-by: lachmanfrantisek <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Doing PoC with Zdravo? @dhodovsk
@TomasTomecek on it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CLI doesn't mention 'dockerfile', so I think you want to add 'dockerfile' also here
colin/core/ruleset/ruleset.py
Outdated
if tags: | ||
for t in tags: | ||
if t not in check_instance.tags: | ||
logger.debug("Check not passed the tag control: {}".format(r)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r
-> t
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, would be better.
colin/core/target.py
Outdated
return target | ||
if os.path.exists(target): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe more specifically if os.path.isfile(target):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, why I always choose the wrong one..;-) Thanks
Signed-off-by: lachmanfrantisek <[email protected]>
Signed-off-by: lachmanfrantisek <[email protected]>
@jpopelka I've corrected the docs and add also support for the dockerfile as a file-like object -- We can use it for easier testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome 👍
@TomasTomecek Thanks for the testing. |
Resolves #66
Resolves #82